package thrift;

import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.transport.TServerSocket;

import java.net.ServerSocket;

/**
 * 单独服务类测试
 * @author qifuguang
 * @date 15/9/11 16:07
 */
public class HelloWorldServer {
    public static void main(String[] args) throws Exception {
        ServerSocket socket = new ServerSocket(8888);
        TServerSocket serverTransport = new TServerSocket(socket);
        TProcessor processor = new com.winwill.thrift.HelloWordService.Processor(new HelloWordServiceImpl());
        TServer.Args args2 = new TServer.Args(serverTransport);
        args2.processor(processor);
        args2.protocolFactory(new TBinaryProtocol.Factory());
        //            args2.protocolFactory(new TCompactProtocol.Factory());
        //            args2.protocolFactory(new TJSONProtocol.Factory());
        TServer server = new TSimpleServer(args2);
        System.out.println("Running server...");
        server.serve();
    }
}
